package kr.hyunist.androidcomplete02saeildamil.ch30;

import kr.hyunist.androidcomplete02saeildamil.R;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.widget.Toast;

public class MusicPlayService extends Service {
	private static final String TAG = "MusicService";
	MediaPlayer mMedia;
	
	@Override
	public void onCreate() {
		//super.onCreate();
		mMedia = MediaPlayer.create(getApplication(), R.raw.turbo);
		mMedia.setLooping(false);
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		super.onStartCommand(intent, flags, startId);
		
		Toast.makeText(this, "서비스 시작!", 0).show();
		mMedia.start();
		
		return START_STICKY;
	}

	@Override
	public void onDestroy() {
		//super.onDestroy();
		Toast.makeText(getApplication(), "서비스 중지!", 0).show();
		mMedia.stop();
	}

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

}
